<?php
/**
 * [PHPFOX_HEADER]
 */

defined('PHPFOX') or exit('NO DICE!');

/**
 *
 *
 * @copyright		[PalxiDevTeam]
 * @author  		NhanLT
 * @package  		Module_Survey
 * @version 		$v01$
 */

class Survey_Component_Controller_Frame extends Phpfox_Component
{
	/**
	 * Class process method wnich is used to execute this component.
	 */
	public function process()
	{
		// We only allow users the ability to upload images.
		if (!Phpfox::isUser())
		{
			exit;
		}
		$vals = $this->request()->get('val');
		
		echo "<script language=\"javascript\" type=\"text/javascript\">";
		if(!($iId = Phpfox::getService("survey.process")->addSurvey($vals))) {
			echo sprintf("window.parent.jQuery(\"#core_js_messages\").empty();");
			foreach(Phpfox_Error::get() as $errorMsg) {
				$msg = sprintf("<div class=\\\"error_message\\\">%s</div>", $errorMsg);
				echo sprintf("window.parent.jQuery(\"#core_js_messages\").append(\"%s\");", $msg);
			}
		} else {
                    // Get New content
                    echo sprintf("window.parent.\$Core.surveyAdded(".$iId.");");
		}
		echo "</script>";
		exit;
	}

	/**
	 * Garbage collector. Is executed after this class has completed
	 * its job and the template has also been displayed.
	 */
	public function clean()
	{
		(($sPlugin = Phpfox_Plugin::get('photo.component_controller_frame_clean')) ? eval($sPlugin) : false);
	}
}

?>